package com.patchmanage.back.result;

/**
 *   错误码
 * @author HuiZhao
 *
 */
public class CodeMsg<T>{
	
	private int code;
	private String msg;
	private T data;
	
	//通用的错误码
	public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
	public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常：%s");
	public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500102, "请求非法");
	public static CodeMsg ACCESS_LIMIT_REACHED= new CodeMsg(500104, "访问太频繁！");
	public static CodeMsg LIST_EMPTY = new CodeMsg(500105, "列表为空，请插入数据！");
	//登录模块 5002XX
	public static CodeMsg LOGIN_NAME_EXIST = new CodeMsg(500201, "账户已存在");
	public static CodeMsg SESSION_ERROR = new CodeMsg(500210, "Session不存在或者已经失效");
	public static CodeMsg PASSWORD_EMPTY = new CodeMsg(500211, "登录密码不能为空");
	public static CodeMsg MOBILE_EMPTY = new CodeMsg(500212, "账号不能为空");
	public static CodeMsg MOBILE_ERROR = new CodeMsg(500213, "账号格式错误");
	public static CodeMsg MOBILE_NOT_EXIST = new CodeMsg(500214, "手机号不存在");
	public static CodeMsg PASSWORD_ERROR = new CodeMsg(500215, "密码错误");
	public static CodeMsg EMAIL_EXIST = new CodeMsg(500216, "邮箱已被注册");
	public static CodeMsg USER_EXIST = new CodeMsg(500217, "账号不存在或密码错误");
	public static CodeMsg LOGIN_ERROR = new CodeMsg(500218, "登录失败");
	public static CodeMsg EMAIL_EMPTY= new CodeMsg(500219, "邮箱不能为空");
	public static CodeMsg TOKEN_EMPTY= new CodeMsg(500220, "Token为空或失效");
	public static CodeMsg ACCOUNT_PASSWORD_ERROR= new CodeMsg(500221, "账户或密码错误");
	public static CodeMsg ACCOUNT_VERIFICATION_CODE_ERROR= new CodeMsg(500222, "验证码验证失败");
	public static CodeMsg ACCOUNT_PASSWORD_VERIFICATION_ERROR= new CodeMsg(500223, "账户或密码错误,请输入验证码");
	public static CodeMsg ACCOUNT_LOCK_ERROR= new CodeMsg(500224, "由于多次登录失败，该账户已被锁定，请稍后在试");

	//资产 部门  资产组
	public static CodeMsg INVENTORY_GROUP_EXIST_ERROR= new CodeMsg(500301, "部门分组下存在资产分组设置，请先删除资产分组设置");
	public static CodeMsg INVENTORY_EXIST_ERROR= new CodeMsg(500302, "部门分组下存在资产记录，请先删除资产信息");
	public static CodeMsg PATCH_EXIST_ERROR= new CodeMsg(500303, "存在子级成员，请先删除");
	public static CodeMsg INVENTORY_ERROR= new CodeMsg(500304, "策略编辑失败");
	public static CodeMsg INVENTORY_MERGE_ERROR= new CodeMsg(500305, "主机名不一致，资产合并失败");
	public static CodeMsg INVENTORY_MERGE_ERROR1= new CodeMsg(500306, "请至少选择2个资产，资产合并失败");
	public static CodeMsg INVENTORY_SETGROUP_ERROR= new CodeMsg(500307, "设置分组失败，存在不可用的资产");



	//密码校验
	public static CodeMsg PASSWORD_VERIFICATION_MAXCHARACTER_ERROR= new CodeMsg(500401, "密码长度过大");
	public static CodeMsg PASSWORD_VERIFICATION_MINCHARACTER_ERROR= new CodeMsg(500402, "密码长度过小");
	public static CodeMsg PASSWORD_VERIFICATION_INCLUD_BIG_ERROR= new CodeMsg(500403, "密码需要包含大写字母");
	public static CodeMsg PASSWORD_VERIFICATION_INCLUD_SMAIL_ERROR= new CodeMsg(500404, "密码需要包含小写字母");
	public static CodeMsg PASSWORD_VERIFICATION_INCLUD_SPECIAL_ERROR= new CodeMsg(500405, "密码需要包含特殊字母");
	public static CodeMsg PASSWORD_VERIFICATION_INCLUD_NUMBER_ERROR= new CodeMsg(500405, "密码需要包含数字");

	public static CodeMsg STRATEGY_BIND_INVENTORY_ERROR= new CodeMsg(500501, "策略未绑定资产","策略未绑定资产");

	//导入导出
	public static CodeMsg EXCEL_IMPORT_FIELD_ERROR= new CodeMsg(500801, "导入失败，请检查标题字段");

	private CodeMsg( ) {
	}

	private CodeMsg( int code,String msg ) {
		this.code = code;
		this.msg = msg;
	}
	public CodeMsg(int code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public CodeMsg fillArgs(Object... args) {
		int code = this.code;
		String message = String.format(this.msg, args);
		return new CodeMsg(code, message);
	}

	@Override
	public String toString() {
		return "CodeMsg [code=" + code + ", msg=" + msg + "]";
	}
	
	
}
